package com.wuxin.ssm.service.impl;


import com.wuxin.ssm.entity.Carshop;
import com.wuxin.ssm.mapper.CarshopMapper;
import com.wuxin.ssm.service.CarShopService;
import com.wuxin.ssm.vo.ShopVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: untitled
 * @ClassName CarShopServiceImpl
 * @description:
 * @author: 李尧坤
 * @create: 2024−12-17 20:37
 * @Version 1.0
 **/
@Service
public class CarShopServiceImpl implements CarShopService {

    @Autowired
    private CarshopMapper carshopMapper;

    @Override
    public int save(Carshop carshop) {
        int num = carshopMapper.insertSelective(carshop);
        return num;
    }

    @Override
    public List<Carshop> getAllCarShopByUserId(Integer uid) {

        List<Carshop> carshopList = carshopMapper.getAllCarShopByUserId(uid);

        return carshopList;
    }

    @Override
    public void deleteById(Integer cid) {
        carshopMapper.deleteByPrimaryKey(cid);
    }

    @Override
    public void updateCarShop(Carshop carshop) {
        carshopMapper.updateByPrimaryKeySelective(carshop);
    }

    @Override
    public Carshop findByUidAndPid(Carshop carshop) {
        Carshop carshop1 = carshopMapper.findByUidAndPid(carshop);
        return carshop1;
    }

    @Override
    public void deleteById2(Integer pid, Integer uid) {
        ShopVo shopVo = new ShopVo();
        shopVo.setPid(pid);
        shopVo.setUid(uid);
        carshopMapper.deleteByPrimaryKey2(shopVo);
    }



}
